/**
 * 
 */
package com.java.test.user.mapper;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;

import com.java.test.user.dto.DrawingTypeInfo;

/**
 * @author 提款类型
 *
 */
@Component
public class DrawingTypeMapper {

	@Autowired
	private JdbcTemplate jdbcTemplate;

	public List<DrawingTypeInfo> selectdrawingList() {

		String sql = "select * from member_drawingtype order by sort desc";

		List<DrawingTypeInfo> list = jdbcTemplate.query(sql, new DrawingTypeInfo());

		return list;

	}

	public int insertdrawingInfo(DrawingTypeInfo info) {
		String sql = "insert into member_drawingtype(type_name,content,add_time,sort)values(?,?,?,0)";
		int i = jdbcTemplate.update(sql, info.getTypeName(), info.getContent(), info.getAddTime());
		return i;
	}

	public DrawingTypeInfo selectdrawingtypeInfobyId(DrawingTypeInfo info) {

		String sql = "select * from member_drawingtype where id=?";

		DrawingTypeInfo obj = null;
		try {
			obj = jdbcTemplate.queryForObject(sql, new DrawingTypeInfo(), info.getId());
		} catch (Exception e) {
			return null;
		}

		return obj;

	}

	public int updatedrawingInfo(DrawingTypeInfo info) {
		String sql = "update member_drawingtype set type_name=?,content=? where id=?";
		int i = jdbcTemplate.update(sql, info.getTypeName(), info.getContent(), info.getId());
		return i;
	}

	public int updatedrawingsortInfo(DrawingTypeInfo info) {
		String sql = "update member_drawingtype set sort=? where id=?";
		int i = jdbcTemplate.update(sql, info.getSort(), info.getId());
		return i;
	}

	public int deletedrawingInfo(DrawingTypeInfo info) {
		String sql = "delete from  member_drawingtype where id=?";
		int i = jdbcTemplate.update(sql, info.getId());
		return i;
	}

}
